﻿using System;
using System.Text;

namespace Reece.Open.Mvc.Common
{
    public static class MenuItems
    {
        public static string MenuItem(string text, string id, string href = null, string css = null)
        {
            StringBuilder output = new StringBuilder(255);
            output.Append("<li");
            if (!string.IsNullOrWhiteSpace(css))
            {
                output.AppendFormat(" class='{0}'", css);
            }
            output.Append(">");
            if (!string.IsNullOrWhiteSpace(href))
            {
                output.AppendFormat("<a href='{0}' id='{1}'>{2}</a>", href, id,text);
            }
            else
            {
                output.AppendFormat("<span id='{0}'>{1}</span>", id, text);
            }
            return output.ToString();
        }

        public static string FirstMenuItem(string text, string id, string href)
        {
            return MenuItem(text, id, href, "first");
        }

        public static string LastMenuItem(string text, string id, string href)
        {
            return MenuItem(text, id, href, "last");
        }
    }
}
